package cn.tedu.boot12.controller;

import cn.tedu.boot12.vo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller
public class helloController {

    /*@RequestMapping("/hello")
    @ResponseBody
    public String hello(String username){
        return "我是:"+ username;
    }*/

    @RequestMapping("/hello")
    public void hello(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String username = request.getParameter("username");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter pw = response.getWriter();
        pw.print("我是:"+username);
        pw.close();
    }

   /* @RequestMapping("/reg")
    @ResponseBody
    public String reg(String username,String password,String nick,int age){
        System.out.println("username = " + username + ", password = " + password + ", nick = " + nick + ", age = " + age);
        return "成功";
    }*/

    @RequestMapping("/reg")
    @ResponseBody
    public String reg(User user){
        System.out.println("user = "+user);
        return "成功";
    }


}
